package ar.com.fiuba.ElectronicCircuitAnalyst.domain.impl;

import java.util.List;

import ar.com.fiuba.ElectronicCircuitAnalyst.domain.api.CircuitElement;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.api.Connection;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.api.Lead;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.exceptions.LeadConnectionLimitReachedException;

public abstract class CircuitElementImpl implements CircuitElement {
	
	protected String name;
	protected List<Lead> inputLeads;
	protected List<Lead> outputLeads;

	public Connection connectToInputLead(int index, Lead from) throws LeadConnectionLimitReachedException {
		Lead to = this.inputLeads.get(index);
		return new ConnectionImpl(from, to);
	}

	public Connection connectFromOutputLead(int index, Lead to) throws LeadConnectionLimitReachedException {
		Lead from = this.outputLeads.get(index);
		return new ConnectionImpl(from, to);
	}

	public String getName() {
		return name;
	}
	
	public List<Lead> getInputLeads() {
		return this.inputLeads;
	}

	public List<Lead> getOutputLeads() {
		return this.outputLeads;
	}

}
